package com.service.single.controller;


import com.service.single.annotation.LogRecord;
import com.service.single.entity.SystemUser;
import com.service.single.service.SystemUserService;
import com.service.single.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author admin
 */
@RestController
@RequestMapping("/system")
public class LoginController {


    @Autowired
    SystemUserService systemUserService;

    @LogRecord("登陆")
    @PostMapping("/login")
    public R login(@RequestBody SystemUser systemUser) {
        return systemUserService.login(systemUser.getUsername(), systemUser.getPassword());
    }

    /**
     * 注册
     */
    @PostMapping("/register")
    public R register(@RequestBody @Validated SystemUser user) {
        return systemUserService.register(user);
    }

}
